<run>
  <precisionModel scale="1.0" offsetx="0.0" offsety="0.0"/>

<case>
  <desc>AA - simple polygons</desc>
  <a>
    POLYGON(
      (10 10, 100 10, 100 100, 10 100, 10 10))
  </a>
  <b>
    POLYGON(
      (50 50, 200 50, 200 200, 50 200, 50 50))
  </b>
<test>
  <op name="intersection" arg1="A" arg2="B">
    POLYGON(
      (50 50, 50 100, 100 100, 100 50, 50 50))
  </op>
</test>
<test>
  <op name="union" arg1="A" arg2="B">
    POLYGON(
      (10 10, 10 100, 50 100, 50 200, 200 200, 200 50, 100 50, 100 10, 10 10))
  </op>
</test>
<test>
  <op name="difference" arg1="A" arg2="B">
    POLYGON(
      (10 10, 10 100, 50 100, 50 50, 100 50, 100 10, 10 10))
  </op>
</test>
<test>
  <op name="symdifference" arg1="A" arg2="B">
    MULTIPOLYGON(
      (
        (10 10, 10 100, 50 100, 50 50, 100 50, 100 10, 10 10)), 
      (
        (50 100, 50 200, 200 200, 200 50, 100 50, 100 100, 50 100)))
  </op>
</test>
</case>

<case>
  <desc>AA - A with hole intersecting B</desc>
  <a>
    POLYGON(
      (20 20, 20 160, 160 160, 160 20, 20 20), 
      (140 140, 40 140, 40 40, 140 40, 140 140))
  </a>
  <b>
    POLYGON(
      (80 100, 220 100, 220 240, 80 240, 80 100))
  </b>
<test>
  <op name="intersection" arg1="A" arg2="B">
    POLYGON(
      (80 140, 80 160, 160 160, 160 100, 140 100, 140 140, 80 140))
  </op>
</test>
<test>
  <op name="union" arg1="A" arg2="B">
    POLYGON(
      (20 20, 20 160, 80 160, 80 240, 220 240, 220 100, 160 100, 160 20, 20 20), 
      (80 100, 80 140, 40 140, 40 40, 140 40, 140 100, 80 100))
  </op>
</test>
<test>
  <op name="difference" arg1="A" arg2="B">
    POLYGON(
      (20 20, 20 160, 80 160, 80 140, 40 140, 40 40, 140 40, 140 100, 160 100, 
      160 20, 20 20))
  </op>
</test>
<test>
  <op name="symdifference" arg1="A" arg2="B">
    MULTIPOLYGON(
      (
        (20 20, 20 160, 80 160, 80 140, 40 140, 40 40, 140 40, 140 100, 160 100, 
        160 20, 20 20)), 
      (
        (80 100, 80 140, 140 140, 140 100, 80 100)), 
      (
        (80 160, 80 240, 220 240, 220 100, 160 100, 160 160, 80 160)))
  </op>
</test>
</case>

<case>
  <desc>AA - simple polygons #2</desc>
  <a>
    POLYGON(
      (20 340, 330 380, 50 40, 20 340))
  </a>
  <b>
    POLYGON(
      (210 320, 140 270, 0 270, 140 220, 210 320))
  </b>
<test>
  <op name="intersection" arg1="A" arg2="B">
    POLYGON(
      (27 270, 140 270, 210 320, 140 220, 28 260, 27 270))
  </op>
</test>
<test>
  <op name="union" arg1="A" arg2="B">
    POLYGON(
      (20 340, 330 380, 50 40, 28 260, 0 270, 27 270, 20 340))
  </op>
</test>
<test>
  <op name="difference" arg1="A" arg2="B">
    POLYGON(
      (20 340, 330 380, 50 40, 28 260, 140 220, 210 320, 140 270, 27 270, 20 340))
  </op>
</test>
<test>
  <op name="symdifference" arg1="A" arg2="B">
    MULTIPOLYGON(
      (
        (20 340, 330 380, 50 40, 28 260, 140 220, 210 320, 140 270, 27 270, 20 340)), 
      (
        (27 270, 28 260, 0 270, 27 270)))
  </op>
</test>
</case>

<case>
  <desc>AA - simple polygons intersecting in P, L and A</desc>
  <a>
    POLYGON((0 0, 110 0, 110 60, 40 60, 180 140, 40 220, 110 260, 0 260, 0 0))
  </a>
  <b>
    POLYGON((220 0, 110 0, 110 60, 180 60, 40 140, 180 220, 110 260, 220 260, 220 0))
  </b>
<test>
  <op name="intersection" arg1="A" arg2="B">
    GEOMETRYCOLLECTION(
      POINT(110 260), 
      LINESTRING(110 0, 110 60), 
      POLYGON(
        (110 100, 40 140, 110 180, 180 140, 110 100)))
  </op>
</test>
<test>
  <op name="union" arg1="A" arg2="B">
    POLYGON(
      (110 0, 0 0, 0 260, 110 260, 220 260, 220 0, 110 0), 
      (110 260, 40 220, 110 180, 180 220, 110 260), 
      (110 100, 40 60, 110 60, 180 60, 110 100))
  </op>
</test>
<test>
  <op name="difference" arg1="A" arg2="B">
    POLYGON(
      (110 0, 0 0, 0 260, 110 260, 40 220, 110 180, 40 140, 110 100, 40 60, 
      110 60, 110 0))
  </op>
</test>
<test>
  <op name="symdifference" arg1="A" arg2="B">
    POLYGON(
      (110 0, 0 0, 0 260, 110 260, 220 260, 220 0, 110 0), 
      (110 260, 40 220, 110 180, 180 220, 110 260), 
      (110 180, 40 140, 110 100, 180 140, 110 180), 
      (110 100, 40 60, 110 60, 180 60, 110 100))
  </op>
</test>
</case>

<case>
  <desc>AA - simple polygons with two touching holes in their symDifference</desc>
  <a>
    POLYGON(
      (0 0, 120 0, 120 50, 50 50, 120 100, 50 150, 120 150, 120 190, 0 190, 
      0 0))
  </a>
  <b>
    POLYGON(
      (230 0, 120 0, 120 50, 190 50, 120 100, 190 150, 120 150, 120 190, 230 190, 
      230 0))
  </b>
<test>
  <op name="symdifference" arg1="A" arg2="B">
    POLYGON(
      (120 0, 0 0, 0 190, 120 190, 230 190, 230 0, 120 0), 
      (120 100, 50 50, 120 50, 190 50, 120 100), 
      (120 100, 190 150, 120 150, 50 150, 120 100))
  </op>
</test>
</case>

<case>
  <desc>AmA - A simple, symDiff contains inversion</desc>
  <a>
    POLYGON(
      (0 0, 210 0, 210 230, 0 230, 0 0))
  </a>
  <b>
    MULTIPOLYGON(
      (
        (40 20, 0 0, 20 40, 60 60, 40 20)), 
      (
        (60 90, 60 60, 90 60, 90 90, 60 90)), 
      (
        (70 120, 90 90, 100 120, 70 120)), 
      (
        (120 70, 90 90, 120 100, 120 70)))
  </b>
<test>
  <op name="symdifference" arg1="A" arg2="B">
    POLYGON(
      (0 0, 0 230, 210 230, 210 0, 0 0), 
      (0 0, 40 20, 60 60, 20 40, 0 0), 
      (60 60, 90 60, 90 90, 60 90, 60 60), 
      (90 90, 120 70, 120 100, 90 90), 
      (90 90, 100 120, 70 120, 90 90))
  </op>
</test>
</case>

<case>
  <desc>AmA - A simple, B connected multiPolygon touching A at vertex</desc>
  <a>
    POLYGON(
      (0 0, 340 0, 340 300, 0 300, 0 0))
  </a>
  <b>
    MULTIPOLYGON(
      (
        (40 20, 0 0, 20 40, 60 60, 40 20)), 
      (
        (60 100, 60 60, 100 60, 100 100, 60 100)))
  </b>
<test>
  <op name="intersection" arg1="A" arg2="B">
    MULTIPOLYGON(
      (
        (40 20, 0 0, 20 40, 60 60, 40 20)), 
      (
        (60 60, 60 100, 100 100, 100 60, 60 60)))
  </op>
</test>
<test>
  <op name="symdifference" arg1="A" arg2="B">
    POLYGON(
      (0 0, 0 300, 340 300, 340 0, 0 0), 
      (0 0, 40 20, 60 60, 20 40, 0 0), 
      (60 60, 100 60, 100 100, 60 100, 60 60))
  </op>
</test>
</case>

<case>
  <desc>AmA - A simple, B connected multiPolygon touching A at interior of edge</desc>
  <a>
    POLYGON(
      (0 0, 120 0, 120 120, 0 120, 0 0))
  </a>
  <b>
    MULTIPOLYGON(
      (
        (60 20, 0 20, 60 60, 60 20)), 
      (
        (60 100, 60 60, 100 60, 100 100, 60 100)))
  </b>
<test>
  <op name="intersection" arg1="A" arg2="B">
    MULTIPOLYGON(
      (
        (60 20, 0 20, 60 60, 60 20)), 
      (
        (60 60, 60 100, 100 100, 100 60, 60 60)))
  </op>
</test>
<test>
  <op name="union" arg1="A" arg2="B">
    POLYGON(
      (0 20, 0 120, 120 120, 120 0, 0 0, 0 20))
  </op>
</test>
<test>
  <op name="difference" arg1="A" arg2="B">
    POLYGON(
      (0 20, 0 120, 120 120, 120 0, 0 0, 0 20), 
      (0 20, 60 20, 60 60, 0 20), 
      (60 60, 100 60, 100 100, 60 100, 60 60))
  </op>
</test>
<test>
  <op name="symdifference" arg1="A" arg2="B">
    POLYGON(
      (0 20, 0 120, 120 120, 120 0, 0 0, 0 20), 
      (0 20, 60 20, 60 60, 0 20), 
      (60 60, 100 60, 100 100, 60 100, 60 60))
  </op>
</test>
</case>

<case>
  <desc>AA - simple polygons with holes</desc>
  <a>
    POLYGON(
      (160 330, 60 260, 20 150, 60 40, 190 20, 270 130, 260 250, 160 330), 
      (140 240, 80 190, 90 100, 160 70, 210 130, 210 210, 140 240))
  </a>
  <b>
    POLYGON(
      (300 330, 190 270, 150 170, 150 110, 250 30, 380 50, 380 250, 300 330), 
      (290 240, 240 200, 240 110, 290 80, 330 170, 290 240))
  </b>
<test>
  <op name="intersection" arg1="A" arg2="B">
    POLYGON(
      (251 104, 217 57, 176 89, 210 130, 210 210, 172 226, 190 270, 217 285, 260 250, 
      263 218, 240 200, 240 110, 251 104))
  </op>
</test>
<test>
  <op name="symdifference" arg1="A" arg2="B">
    MULTIPOLYGON(
      (
        (217 57, 190 20, 60 40, 20 150, 60 260, 160 330, 217 285, 190 270, 172 226, 
        140 240, 80 190, 90 100, 160 70, 176 89, 217 57)), 
      (
        (217 57, 251 104, 290 80, 330 170, 290 240, 263 218, 260 250, 217 285, 300 330, 
        380 250, 380 50, 250 30, 217 57)), 
      (
        (263 218, 270 130, 251 104, 240 110, 240 200, 263 218)), 
      (
        (172 226, 210 210, 210 130, 176 89, 150 110, 150 170, 172 226)))
  </op>
</test>
</case>

<case>
  <desc>AA - simple polygons with hole touching shell</desc>
  <a>
    POLYGON ((20 0, 20 160, 200 160, 200 0, 20 0))
  </a>
  <b>
    POLYGON ((220 80, 0 80, 0 240, 220 240, 220 80), 
  	(100 80, 120 120, 80 120, 100 80))
  </b>
<test>
  <op name="intersection" arg1="A" arg2="B">
    POLYGON ((20 80, 20 160, 200 160, 200 80, 100 80, 20 80), 
  (100 80, 120 120, 80 120, 100 80))
  </op>
</test>
<test>
  <op name="union" arg1="A" arg2="B">
    POLYGON ((20 0, 20 80, 0 80, 0 240, 220 240, 220 80, 200 80, 200 0, 20 0))
  </op>
</test>
<test>
  <op name="difference" arg1="A" arg2="B">
    MULTIPOLYGON (((20 0, 20 80, 100 80, 200 80, 200 0, 20 0)), 
  ((100 80, 80 120, 120 120, 100 80)))
  </op>
</test>
<test>
  <op name="symdifference" arg1="A" arg2="B">
    MULTIPOLYGON (((20 0, 20 80, 100 80, 200 80, 200 0, 20 0)), 
  ((200 80, 200 160, 20 160, 20 80, 0 80, 0 240, 220 240, 220 80, 200 80)), 
  ((100 80, 80 120, 120 120, 100 80)))
  </op>
</test>
</case>

<case>
  <desc>mAmA - complex polygons touching and overlapping</desc>
  <a>
    MULTIPOLYGON(
      (
        (120 340, 120 200, 140 200, 140 280, 160 280, 160 200, 180 200, 180 280, 200 280, 
        200 200, 220 200, 220 340, 120 340)), 
      (
        (360 200, 220 200, 220 180, 300 180, 300 160, 220 160, 220 140, 300 140, 300 120, 
        220 120, 220 100, 360 100, 360 200)))
  </a>
  <b>
    MULTIPOLYGON(
      (
        (100 220, 100 200, 300 200, 300 220, 100 220)), 
      (
        (280 180, 280 160, 300 160, 300 180, 280 180)), 
      (
        (220 140, 220 120, 240 120, 240 140, 220 140)), 
      (
        (180 220, 160 240, 200 240, 180 220)))
  </b>
<test>
  <op name="getboundary" arg1="A">
    MULTILINESTRING(
      (120 340, 120 200, 140 200, 140 280, 160 280, 160 200, 180 200, 180 280, 200 280, 
      200 200, 220 200, 220 340, 120 340), 
      (360 200, 220 200, 220 180, 300 180, 300 160, 220 160, 220 140, 300 140, 300 120, 
      220 120, 220 100, 360 100, 360 200))
  </op>
</test>
<test>
  <op name="convexhull" arg1="A">
    POLYGON(
      (220 100, 120 200, 120 340, 220 340, 360 200, 360 100, 220 100))
  </op>
</test>
<test>
  <op name="intersection" arg1="A" arg2="B">
    GEOMETRYCOLLECTION(
      POINT(200 240), 
      LINESTRING(300 200, 220 200), 
      LINESTRING(280 180, 300 180), 
      LINESTRING(300 180, 300 160), 
      LINESTRING(300 160, 280 160), 
      LINESTRING(220 140, 240 140), 
      LINESTRING(240 120, 220 120), 
      POLYGON(
        (120 200, 120 220, 140 220, 140 200, 120 200)), 
      POLYGON(
        (160 200, 160 220, 180 220, 180 200, 160 200)), 
      POLYGON(
        (180 240, 180 220, 160 240, 180 240)), 
      POLYGON(
        (200 200, 200 220, 220 220, 220 200, 200 200)))
  </op>
</test>
<test>
  <op name="union" arg1="A" arg2="B">
    POLYGON(
      (120 220, 120 340, 220 340, 220 220, 300 220, 300 200, 360 200, 360 100, 220 100, 
      220 120, 220 140, 220 160, 280 160, 280 180, 220 180, 220 200, 200 200, 180 200, 160 200, 
      140 200, 120 200, 100 200, 100 220, 120 220), 
      (200 240, 200 280, 180 280, 180 240, 200 240), 
      (200 240, 180 220, 200 220, 200 240), 
      (160 240, 160 280, 140 280, 140 220, 160 220, 160 240), 
      (240 120, 300 120, 300 140, 240 140, 240 120))
  </op>
</test>
<test>
  <op name="difference" arg1="A" arg2="B">
    MULTIPOLYGON(
      (
        (120 220, 120 340, 220 340, 220 220, 200 220, 200 240, 200 280, 180 280, 180 240, 
        160 240, 160 280, 140 280, 140 220, 120 220)), 
      (
        (160 220, 160 240, 180 220, 160 220)), 
      (
        (300 200, 360 200, 360 100, 220 100, 220 120, 240 120, 300 120, 300 140, 240 140, 
        220 140, 220 160, 280 160, 300 160, 300 180, 280 180, 220 180, 220 200, 300 200)))
  </op>
</test>
<test>
  <op name="symdifference" arg1="A" arg2="B">
    MULTIPOLYGON(
      (
        (120 220, 120 340, 220 340, 220 220, 200 220, 200 240, 200 280, 180 280, 180 240, 
        160 240, 160 280, 140 280, 140 220, 120 220)), 
      (
        (120 220, 120 200, 100 200, 100 220, 120 220)), 
      (
        (140 200, 140 220, 160 220, 160 200, 140 200)), 
      (
        (160 220, 160 240, 180 220, 160 220)), 
      (
        (180 200, 180 220, 200 220, 200 200, 180 200)), 
      (
        (180 220, 180 240, 200 240, 180 220)), 
      (
        (220 200, 220 220, 300 220, 300 200, 360 200, 360 100, 220 100, 220 120, 220 140, 
        220 160, 280 160, 280 180, 220 180, 220 200), 
        (240 120, 300 120, 300 140, 240 140, 240 120)))
  </op>
</test>
</case>

<case>
  <desc>mAmA - complex polygons touching</desc>
  <a>
    MULTIPOLYGON(
      (
        (100 200, 100 180, 120 180, 120 200, 100 200)), 
      (
        (60 240, 60 140, 220 140, 220 160, 160 160, 160 180, 200 180, 200 200, 160 200, 
        160 220, 220 220, 220 240, 60 240), 
        (80 220, 80 160, 140 160, 140 220, 80 220)), 
      (
        (280 220, 240 180, 260 160, 300 200, 280 220)))
  </a>
  <b>
    MULTIPOLYGON(
      (
        (80 220, 80 160, 140 160, 140 220, 80 220), 
        (100 200, 100 180, 120 180, 120 200, 100 200)), 
      (
        (220 240, 220 220, 160 220, 160 200, 220 200, 220 180, 160 180, 160 160, 220 160, 
        220 140, 320 140, 320 240, 220 240), 
        (240 220, 240 160, 300 160, 300 220, 240 220)))
  </b>
<test>
  <op name="getboundary" arg1="A">
    MULTILINESTRING(
      (100 200, 100 180, 120 180, 120 200, 100 200), 
      (60 240, 60 140, 220 140, 220 160, 160 160, 160 180, 200 180, 200 200, 160 200, 
      160 220, 220 220, 220 240, 60 240), 
      (80 220, 80 160, 140 160, 140 220, 80 220), 
      (280 220, 240 180, 260 160, 300 200, 280 220))
  </op>
</test>
<test>
  <op name="convexhull" arg1="A">
    POLYGON(
      (60 140, 60 240, 220 240, 280 220, 300 200, 260 160, 220 140, 60 140))
  </op>
</test>
<test>
  <op name="intersection" arg1="A" arg2="B">
    GEOMETRYCOLLECTION(
      POINT(240 180), 
      POINT(260 160), 
      POINT(280 220), 
      POINT(300 200), 
      LINESTRING(100 200, 100 180), 
      LINESTRING(100 180, 120 180), 
      LINESTRING(120 180, 120 200), 
      LINESTRING(120 200, 100 200), 
      LINESTRING(220 140, 220 160), 
      LINESTRING(220 160, 160 160), 
      LINESTRING(160 160, 160 180), 
      LINESTRING(160 180, 200 180), 
      LINESTRING(200 200, 160 200), 
      LINESTRING(160 200, 160 220), 
      LINESTRING(160 220, 220 220), 
      LINESTRING(220 220, 220 240), 
      LINESTRING(80 220, 80 160), 
      LINESTRING(80 160, 140 160), 
      LINESTRING(140 160, 140 220), 
      LINESTRING(140 220, 80 220))
  </op>
</test>
<test>
  <op name="union" arg1="A" arg2="B">
    MULTIPOLYGON(
      (
        (220 140, 60 140, 60 240, 220 240, 320 240, 320 140, 220 140), 
        (200 200, 200 180, 220 180, 220 200, 200 200), 
        (240 220, 240 180, 240 160, 260 160, 300 160, 300 200, 300 220, 280 220, 240 220)), 
      (
        (240 180, 280 220, 300 200, 260 160, 240 180)))
  </op>
</test>
<test>
  <op name="difference" arg1="A" arg2="B">
    MULTIPOLYGON(
      (
        (100 180, 100 200, 120 200, 120 180, 100 180)), 
      (
        (220 140, 60 140, 60 240, 220 240, 220 220, 160 220, 160 200, 200 200, 200 180, 
        160 180, 160 160, 220 160, 220 140), 
        (80 220, 80 160, 140 160, 140 220, 80 220)), 
      (
        (240 180, 280 220, 300 200, 260 160, 240 180)))
  </op>
</test>
<test>
  <op name="symdifference" arg1="A" arg2="B">
    MULTIPOLYGON(
      (
        (220 140, 60 140, 60 240, 220 240, 320 240, 320 140, 220 140), 
        (200 200, 200 180, 220 180, 220 200, 200 200), 
        (240 220, 240 180, 240 160, 260 160, 300 160, 300 200, 300 220, 280 220, 240 220)), 
      (
        (240 180, 280 220, 300 200, 260 160, 240 180)))
  </op>
</test>
</case>

<case>
  <desc>AA - hole intersecting boundary to produce line</desc>
  <a>
    POLYGON(
      (60 160, 140 160, 140 60, 60 60, 60 160))
  </a>
  <b>
    POLYGON(
      (160 160, 100 160, 100 100, 160 100, 160 160), 
      (140 140, 120 140, 120 120, 140 120, 140 140))
  </b>
<test>
  <op name="getboundary" arg1="A">
    LINESTRING(60 160, 140 160, 140 60, 60 60, 60 160)
  </op>
</test>
<test>
  <op name="convexhull" arg1="A">
    POLYGON(
      (60 60, 60 160, 140 160, 140 60, 60 60))
  </op>
</test>
<test>
  <op name="intersection" arg1="A" arg2="B">
    GEOMETRYCOLLECTION(
      LINESTRING(140 140, 140 120), 
      POLYGON(
        (100 160, 140 160, 140 140, 120 140, 120 120, 140 120, 140 100, 100 100, 100 160)))
  </op>
</test>
<test>
  <op name="union" arg1="A" arg2="B">
    POLYGON(
      (60 160, 100 160, 140 160, 160 160, 160 100, 140 100, 140 60, 60 60, 60 160))
  </op>
</test>
<test>
  <op name="difference" arg1="A" arg2="B">
    MULTIPOLYGON(
      (
        (60 160, 100 160, 100 100, 140 100, 140 60, 60 60, 60 160)), 
      (
        (140 140, 140 120, 120 120, 120 140, 140 140)))
  </op>
</test>
<test>
  <op name="symdifference" arg1="A" arg2="B">
    MULTIPOLYGON(
      (
        (60 160, 100 160, 100 100, 140 100, 140 60, 60 60, 60 160)), 
      (
        (140 140, 140 160, 160 160, 160 100, 140 100, 140 120, 120 120, 120 140, 140 140)))
  </op>
</test>
</case>

</run>
